/* 加载器以及一些初始的样式 */
#loader {
  position: fixed;
  color: #fff;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 2147483647;
  font-size: 14px;
}
/* 开屏画面 */
#loader > .loader--section {
  z-index: 100;
  position: fixed;
  top: 0;
  background: var(--theme-primary) url(./body.svg);
  background-size: 200% auto;
  background-repeat: repeat-y;

  width: 50%;
  height: 100%;
  -webkit-transform: translateX(0);
  -ms-transform: translateX(0);
  transform: translateX(0);
}
#loader > .loader--section.section-left {
  left: 0;
}
#loader > .loader--section.section-right {
  right: 0;
  background-position-x: right;
}

/* 内容区域 */
#loader > .loader--content {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  z-index: 101;
  text-align: center;
}
/* 加载动画 */
@-webkit-keyframes page-loading-spin {
  0% {
    -webkit-transform: rotate(0deg);
    -ms-transform: rotate(0deg);
    transform: rotate(0deg);
  }

  100% {
    -webkit-transform: rotate(360deg);
    -ms-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

@keyframes page-loading-spin {
  0% {
    -webkit-transform: rotate(0deg);
    -ms-transform: rotate(0deg);
    transform: rotate(0deg);
  }

  100% {
    -webkit-transform: rotate(360deg);
    -ms-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

#loader .loader--icon,
#loader .loader--icon:before,
#loader .loader--icon:after {
  --animation-duration: 2s;

  color: #fff;
  border-radius: 50%;
  border: 3px solid transparent;

  -webkit-animation: page-loading-spin var(--animation-duration) linear infinite;
  -ms-animation: page-loading-spin var(--animation-duration) linear infinite;
  -moz-animation: page-loading-spin var(--animation-duration) linear infinite;
  -o-animation: page-loading-spin var(--animation-duration) linear infinite;
  animation: page-loading-spin var(--animation-duration) linear infinite;
}

#loader .loader--icon {
  border-top-color: currentColor;
  font-size: 120px;
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-bottom: 0.05em;
}

#loader .loader--icon:before {
  --animation-duration: 3s;
  border-right-color: currentColor;
  position: absolute;
  content: "";
  top: 0.05em;
  left: 0.05em;
  right: 0.05em;
  bottom: 0.05em;
}

#loader .loader--icon:after {
  --animation-duration: 1.5s;
  border-left-color: currentColor;
  position: absolute;
  content: "";
  top: 0.15em;
  left: 0.15em;
  right: 0.15em;
  bottom: 0.15em;
}

/* 加载等待提示文本 */
#loader .app-version {
  font-weight: normal;
  font-style: italic;
  font-size: 0.9em;
  opacity: 0.7;
}

#loader .loader--message {
  padding: 0 1em;
}

#loader .loader--timeout {
  color: var(--theme-danger);
  transform: scale(0);
  max-width: 280px;
  margin-top: 0.5em;
  pointer-events: all;
}
/* 超时后显示的内容 */
#loader.timeout .loader--timeout {
  transition: all 0.2s;
  transform: scale(1);
}
#loader.timeout .loader--timeout:hover {
  transform: translateY(-0.25em) scale(1);
}

/* Loaded */

body.loaded #loader {
  color: var(--theme-danger);

  visibility: hidden;
  -webkit-transform: translateY(-100%);
  -ms-transform: translateY(-100%);
  transform: translateY(-100%);
  -webkit-transition:
    all 0.3s 1s ease-out,
    color 0.45s;
  transition:
    all 0.3s 1s ease-out,
    color 0.45s;
}
body.loaded #loader > .loader--section.section-left {
  opacity: 0.5;
  -webkit-transform: translateX(-100%);
  -ms-transform: translateX(-100%);
  transform: translateX(-100%);
  -webkit-transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}
body.loaded #loader > .loader--section.section-right {
  opacity: 0.5;
  -webkit-transform: translateX(100%);
  -ms-transform: translateX(100%);
  transform: translateX(100%);
  -webkit-transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}
/* 正常加载完成情况下将不显示此按钮，即使超时检测时间已结束 */
body.loaded #loader .loader--timeout {
  opacity: 0;
  transform: scale(0);
  transition: none;
}

body.loaded #loader .loader--icon,
body.loaded #loader .loader--icon:before,
body.loaded #loader .loader--icon:after {
  color: var(--theme-danger);
}

/* 屏幕为纵向时 */
@media screen and (orientation: portrait) {
  #loader > .loader--section {
    background-size: auto 100%;
    background-repeat: no-repeat;

    width: 100%;
    height: 50%;
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
  }

  #loader > .loader--section.section-right {
    bottom: 0;
    top: initial;
  }
  body.loaded #loader {
    -webkit-transform: translateX(-100%);
    -ms-transform: translateX(-100%);
    transform: translateX(-100%);
  }
  body.loaded #loader > .loader--section.section-left {
    -webkit-transform: translateY(-100%);
    -ms-transform: translateY(-100%);
    transform: translateY(-100%);
  }
  body.loaded #loader > .loader--section.section-right {
    -webkit-transform: translateY(100%);
    -ms-transform: translateY(100%);
    transform: translateY(100%);
  }
}
